package com.shell.arouter.demo.motion

import android.view.View
import androidx.core.app.ActivityOptionsCompat
import androidx.core.util.Pair
import com.alibaba.android.arouter.facade.annotation.Route
import com.durian.base.frame.easyrouter.EasyRouter
import com.henanjianye.soon.communityo2o2.R
import com.shell.arouter.demo.IHomeAction
import com.shell.arouter.extend.PATH_ACTIVITY_MATERIAL
import com.shell.arouter.extend.PATH_FRAGMENT_MOTION
import com.shell.arouter.ui.FragmentCommon
import kotlinx.android.synthetic.main.fragment_motion.*

/**
 * 说明：FragmentMotion
 * <p/>
 * 作者：fanly
 * <p/>
 * 类型：Class
 * <p/>
 * 时间：2020-02-25 10:37
 * <p/>
 * 版本：version 1.0
 */
@Route(path = PATH_FRAGMENT_MOTION)
class FragmentMotion : FragmentCommon() {
    override fun getRootViewResID(): Int {
        return R.layout.fragment_motion
    }

    override fun onFirstUserVisible() {
        super.onFirstUserVisible()
        btnTranslateExplode.setOnClickListener {
//            val intent = Intent(activity(), ActivitySampleTranslate::class.java)
////            val bundle = ActivityOptionsCompat.makeBasic().toBundle()
//            val bundle = ActivityOptionsCompat.makeSceneTransitionAnimation(activity()).toBundle()
//            startActivity(intent, bundle)
            EasyRouter.build("/motion/sampletranslate")
                    .withOptionsCompat(ActivityOptionsCompat.makeSceneTransitionAnimation(activity()))
                    .withInt("key",1)
                    .navigation(activity())
        }
        btnTranslateFade.setOnClickListener {
            EasyRouter.build("/motion/sampletranslate")
                    .withOptionsCompat(ActivityOptionsCompat.makeSceneTransitionAnimation(activity()))
                    .withInt("key",2)
                    .navigation(activity())
        }
        btnTranslateSlide.setOnClickListener {
            EasyRouter.build("/motion/sampletranslate")
                    .withOptionsCompat(ActivityOptionsCompat.makeSceneTransitionAnimation(activity()))
                    .withInt("key",3)
                    .navigation(activity())
        }
        btnStart.setOnClickListener {
            val pairs = arrayOf<Pair<View,String>>(Pair.create(btnStart,"share"),Pair.create(tvHello,"share1"))
            EasyRouter.build("/motion/sampleshared")
                    .withOptionsCompat(ActivityOptionsCompat
                            .makeSceneTransitionAnimation(activity(),*pairs))
                    .navigation(activity())
        }
    }

    override fun isShowTitleBar(): Boolean {
        return true
    }

    override fun isShowTitleBarBack(): Boolean {
        return true
    }

    override fun bindTitleBarText(): String {
        return "Motion"
    }
}

class ActionMotion : IHomeAction {
    override fun todo() {
        EasyRouter.buildByFragment(PATH_FRAGMENT_MOTION, PATH_ACTIVITY_MATERIAL).navigation()
    }

    override fun name(): String {
        return "Motion"
    }

}